<?php $banners = Doctrine::getTable('Banner')->findByPosition($position, (isset($limit) ? $limit : 0));?>
  
<?php foreach ($banners as $banner): ?>
  <?php if($banner->getPath() && file_exists(sfConfig::get('sf_upload_dir').'/banner/'.$banner->getPath())): ?>
  
    <?php if($banner->getExt() =='swf'): ?>
        <object width="<?php echo $banner->getWidth()?>" height="<?php echo $banner->getHeight()?>" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="margin-bottom:5px;">
          <param value="<?php echo '/uploads/banner/'.$banner->getPath()?>" name="movie">
          <param value="high" name="quality">
          <param name="wmode" value="transparent">
          <embed width="<?php echo $banner->getWidth()?>" height="<?php echo $banner->getHeight()?>"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="<?php echo '/uploads/banner/'.$banner->getPath()?>" allowscriptaccess="sameDomain" wmode="transparent" />
        </object>
        <br clear="all">
    <?php else:?>
      <a href="<?php echo $banner->getLink() ? $banner->getLink() : '#'?>" target="<?php echo $banner->getTarget() ? '_blank' : '_parent'?>" title="<?php echo $banner?>">
        <?php 
        $style = "max-width:{$banner->getWidth()}px;";
        $style .= $banner->getHeight() ? "max-height:{$banner->getHeight()}px;" : ''?>
        <?php echo image_tag('/uploads/banner/'.$banner->getPath(), array('style'=>$style, 'alt'=>$banner, 'title'=>$banner))?>
      </a>
      <br clear="all">
      <br clear="all">
    <?php endif?>

  <?php endif;?>
<?php endforeach;?>